from django.db import models


# 班级表视图，从学校方面给的数据库里的视图拿
class ClassDbView(models.Model):
    class_id = models.CharField(verbose_name='班号', max_length=100, primary_key=True, db_column='bh')
    class_name = models.CharField(verbose_name='班级名称', max_length=50, db_column='bjmc')
    faculty_code = models.CharField(verbose_name='单位号', default='', max_length=30, db_column='dwh')
    major_code = models.CharField(verbose_name='专业代码', default='', max_length=50, db_column='zym')
    grade_name = models.CharField(verbose_name='所属年级', max_length=100, db_column='ssnj')
    campus_code = models.CharField(verbose_name='所在校区码', max_length=20, db_column='xqh')
    class_type = models.IntegerField(verbose_name='班级类型（1本科生班级，2成教生班级，3研究生班级）', db_column='bjlx')

    class Meta:
        db_table = 'class_view'
        app_label = 'dgut'
        managed = False  # 不用做migrate


# 组织部门表视图，从学校方面给的数据库里的视图拿
class FacultyDbView(models.Model):
    faculty_code = models.CharField(verbose_name='单位号', primary_key=True, max_length=30, db_column='zzdm')
    faculty_title = models.CharField(verbose_name='单位名称',  max_length=50, db_column='zzmc')
    parent_code = models.CharField(verbose_name='上级单位号', null=True, max_length=30, db_column='parent_id')

    class Meta:
        db_table = 'dwbmdm'
        app_label = 'dgut'
        managed = False  # 不用做migrate


# 专业表视图，从学校方面给的数据库里的视图拿
class MajorDbView(models.Model):
    major_code = models.CharField(verbose_name='专业编号', primary_key=True, max_length=30, db_column='zybh')
    major_name = models.CharField(verbose_name='专业名称',  max_length=50, db_column='zymc')
    faculty_code = models.CharField(verbose_name='院系编号',  max_length=30, db_column='yxbh')

    class Meta:
        db_table = 'major_view'
        app_label = 'dgut'
        managed = False  # 不用做migrate


# 组织部门表
class Faculty(models.Model):
    faculty_code = models.CharField(verbose_name='单位号', max_length=30, default='')
    faculty_title = models.CharField(verbose_name='单位名称', max_length=50, default='')
    parent_code = models.CharField(verbose_name='上级单位号', null=True, max_length=30, default='')

    class Meta:
        db_table = 'faculty'
        verbose_name_plural = verbose_name = '组织部门表'
